package com.ruoyi.rsikManage.service.Impl;

import com.ruoyi.rsikManage.domain.MonitorPoint;
import com.ruoyi.rsikManage.domain.MonitorPointHistory;
import com.ruoyi.rsikManage.mapper.MonitorPointHistoryMapper;
import com.ruoyi.rsikManage.mapper.MonitorPointMapper;
import com.ruoyi.rsikManage.service.MonitorPointHistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class MonitoryPointHistoryServiceImpl implements MonitorPointHistoryService {
    @Autowired
    MonitorPointHistoryMapper monitorPointHistoryMapper;
    @Autowired
    MonitorPointMapper monitorPointMapper;

    @Override
    public List<MonitorPointHistory> selectMonitorPointHistory(String apeId, Date startTime, Date endTime, String isOnline) {
        return monitorPointHistoryMapper.selectMonitorPointHistory(apeId, startTime, endTime, isOnline);
    }

    @Override
    public int recordCurrentStatusOfAllMonitoringPoint() {
        List<MonitorPoint> monitorPoints = monitorPointMapper.selectAllMonitorPoints();
        //System.out.println("-------------加入历史表----开始--------------");
        monitorPoints.forEach(System.out::println);
        //System.out.println("-------------加入历史表----结束------------");

        return monitorPointHistoryMapper.recordCurrentStatusOfAllMonitoringPoint(monitorPoints);
    }


    @Override
    public int recordCurrentStatusOfAllMonitoringPointForUnitCodes() {
        List<MonitorPoint> monitorPoints = monitorPointMapper.selectAllMonitorPointsForUnitCodes();
        //System.out.println("-------------加入历史表----开始--------------");
        monitorPoints.forEach(System.out::println);
        //System.out.println("-------------加入历史表----结束------------");

        return monitorPointHistoryMapper.recordCurrentStatusOfAllMonitoringPoint(monitorPoints);
    }
}
